#ifndef FRAME_H
#define FRAME_H

#include <stdint.h>
#include <stddef.h>

#define FRAME_START 0xAA55
#define FILE_CHUNK_SIZE 512

typedef enum {
    CMD_DATA = 0x01,
    CMD_FILE_START = 0x02,
    CMD_FILE_CHUNK = 0x03,
    CMD_FILE_END = 0x04,
    CMD_VIDEO_START = 0x05,
    CMD_VIDEO_FRAME = 0x06,
    CMD_VIDEO_END = 0x07
} CommandType;

#pragma pack(push, 1)
typedef struct {
    uint16_t start_flag;
    uint8_t command;
    uint16_t data_length;
    uint16_t crc16;
} FrameHeader;
#pragma pack(pop)

uint16_t crc16(const uint8_t *data, size_t length);

#endif // FRAME_H